package com.alibaba.citrus.cr.sales.plan.dto.api.request;

import com.alibaba.citrus.cr.sales.plan.BaseRequest;
import com.alibaba.citrus.cr.sales.plan.CustomLockKey;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * 批量审批请求体
 * @author:suqing.tjf
 * @date:2021/10/14
 */
@Getter
@Setter
public class SalesPlanBatchAuditRequest extends BaseRequest implements CustomLockKey {

    private static final long serialVersionUID = 1255947198654950028L;

    /**
     * 维度信息
     */
    private List<DimensionDTO>  dimensionDTOList;

    /**
     * 模型类型
     * 1、计划提报 2、计划调整
     */
    private Integer modelType;

    /**
     * 模型id
     * 计划任务id或者调整任务id
     */
    private String modelId;

    /**
     * 审批意见
     */
    private String comment;

    /**
     * 审批动作
     * approve 审核通过
     * reject  审核拒绝
     * sendBack 审核撤回
     */
    private String action;

    @Override
    public String getCustomLockCondition() {
        if (CollectionUtils.isEmpty(dimensionDTOList)) {
            return null;
        }
        return modelId + modelType.longValue() + dimensionDTOList.get(0).getBizType();
    }
}
